package com.xsy.ftp;

import org.apache.commons.io.Charsets;
import org.apache.commons.io.IOUtils;
import org.apache.commons.net.ftp.FTPClient;

import java.io.IOException;
import java.io.InputStream;


public class Client {

    public static boolean uploadFile(String fileName, String result) {
        FTPClient ftpClient = Global.pool.getResource();
        boolean flag = false;
        try {
            InputStream inputStream = IOUtils.toInputStream(result, Charsets.UTF_8);
            flag = ftpClient.storeFile(fileName, inputStream);
            IOUtils.closeQuietly(inputStream);
        } catch (IOException e) {
            e.printStackTrace();
        }
        Global.pool.returnResource(ftpClient);
        return flag;
    }

}
